package com.keeson.android_cli.base;

import android.content.Context;

import androidx.lifecycle.LifecycleObserver;
import androidx.viewbinding.ViewBinding;
import com.keeson.android_cli.util.ToastUtils;


/**
 * Created by jiaqiZHou
 * on 2020/12/4
 */
public abstract class BaseMvpFragment<T extends ViewBinding,P extends BasePresenter> extends BaseFragment<T> implements BaseView {

    protected P mPresenter;

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        mPresenter = initPresenter();
        getLifecycle().addObserver((LifecycleObserver) mPresenter);
    }

    public abstract P initPresenter();

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mPresenter != null) {
            mPresenter.detach();
        }
    }

    @Override
    public void showProgress(String s) {
        showLoadingDialog(s);
    }

    @Override
    public void dismissProgress() {
        dismissLoadingDialog();
    }


    @Override
    public void showLoadingPage() {

    }

    @Override
    public void showEmptyPage() {

    }

    @Override
    public void showErrorPage() {

    }

    @Override
    public void showNetWorkErrorPage() {

    }

    @Override
    public void showSucessPage() {

    }

    @Override
    public void toast(String s) {
        ToastUtils.showShort(getActivity(), s);
    }
}
